<?php
namespace app\index\model;
use think\Exception;
use think\Model;
use think\Db;
class User extends Model{
    public function login(){
        $input = input();
//        var_dump($input);
        if(!$this->validate()->validateData($input)){
            throw new Exception($this->getError());
        }
        $dbUser = $this->getByLogin($input['login']);
        if(empty($dbUser)){
            throw new Exception("账户不存在");
        }
        if ($dbUser['password']!=$input['password']){
            throw new Exception("密码错误");
        }
        $dbInformation = $this->query('select * from information join user on user_id = user.id WHERE user.id=?',[$dbUser['id']]);
        return $dbInformation;
    }
}
